<!--异步组件-->
<template>
    <div>
        <button @click="loadComponent">加载组件</button>
        <component v-if="isComponentLoaded" :is="initComponent"></component>
    </div>
</template>

<script>
export default {
    name: "AsynchronousComponent",
    data(){
        return {
            isComponentLoaded: false,
            initComponent:null
        }
    },
    methods:{
        /**
         * 加载组件
         */
        loadComponent(){
            import('./ComponentA.vue').then((module)=>{
                this.initComponent = module.default;
                this.isComponentLoaded = true;
            })
        }
    },
}
</script>

<style scoped>

</style>
